package com.tzy.user.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tzy.common.constant.Result;
import com.tzy.common.controller.BaseController;
import com.tzy.common.entity.ShippingAddress;
import com.tzy.user.service.ShippingAddressService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * <p>
 * 收货地址表 前端控制器
 * </p>
 *
 * @author 谭同学
 * @since 2022-03-26
 */
@RestController
@RequestMapping("/user/shipping-address")
public class ShippingAddressController extends BaseController {
    @Resource
    private ShippingAddressService shippingAddressService;
    @PostMapping("/save")
    public Result save(@RequestBody ShippingAddress shippingAddress){
        boolean save = shippingAddressService.save(shippingAddress);
        return Result.success(save);
    }
    @GetMapping("/list")
    public Result listByUserId(HttpServletRequest request){
        int userId = getUserId(request);
        List<ShippingAddress> list = shippingAddressService.list(userId);
        return  Result.success(list);
    }

}
